angular.module('starter.services', ['angularSoap', 'soapclient2'])

.factory('Chats', function() {
  // Might use a resource here that returns a JSON array

  // Some fake testing data
  var chats = [{
    id: 0,
    name: 'Ben Sparrow',
    lastText: 'You on your way?',
    face: 'img/ben.png'
  }, {
    id: 1,
    name: 'Max Lynx',
    lastText: 'Hey, it\'s me',
    face: 'img/max.png'
  }, {
    id: 2,
    name: 'Adam Bradleyson',
    lastText: 'I should buy a boat',
    face: 'img/adam.jpg'
  }, {
    id: 3,
    name: 'Perry Governor',
    lastText: 'Look at my mukluks!',
    face: 'img/perry.png'
  }, {
    id: 4,
    name: 'Mike Harrington',
    lastText: 'This is wicked good ice cream.',
    face: 'img/mike.png'
  }];

  return {
    all: function() {
      return chats;
    },
    remove: function(chat) {
      chats.splice(chats.indexOf(chat), 1);
    },
    get: function(chatId) {
      for (var i = 0; i < chats.length; i++) {
        if (chats[i].id === parseInt(chatId)) {
          return chats[i];
        }
      }
      return null;
    }
  };
});

app.service('USHolidayService', ['$soap', '$http','$q', function ($soap, $http, $q) {

    // var webServiceURL = "http://www.pttplc.com/webservice/pttinfo.asmx";
    var webServiceURL = "http://www.holidaywebservice.com/HolidayService_v2/HolidayService2.asmx";
    //var webServiceURL = "http://test.insminer.cn:8090/rs/common/getEquipList";
    // var webServiceURL = "http://localhost/Semis/AppService.asmx";

    return {
        HelloWorld: function () {
            return $soap.post(webServiceURL, 'HelloWorld');
        },
        GetCountriesAvailable: function () {
            return $soap.post(webServiceURL, 'GetCountriesAvailable');
        },
        //GetCountriesAvailable: function () {
        //    //return $soap.post(webServiceURL, 'GetCountriesAvailable');
        //   // var deferred = $q.defer();
        //    $http({
        //        url: webServiceURL+"",
        //        method: "POST",
        //        headers: {
        //            'Content-Type': 'text/xml'
        //        },
        //        params: null,
        //        data: {}
        //    }).success(function (data, status, config, headers) {
        //        // deferred.resolve(data);
        //        console.log(data);
        //    }).error(function (error) {
        //        // deferred.reject(error);
        //        console.log(error);
        //    });
        //    return "";
        //},
        abc:function(){
            return [
            { id: 1, text: "111111", url: "img/ionic.png" }, { id: 2, text: "222222", url: "img/adam.jpg" }, { id: 3, text: "333333", url: "img/ben.png" },
            { id: 4, text: "444444", url: "img/max.png" }, { id: 5, text: "555555", url: "img/mike.png" }, { id: 6, text: "666666", url: "img/perry.png" },
            { id: 7, text: "777777", url: "img/ionic.png" }, { id: 8, text: "888888", url: "img/ionic.png" }, { id: 9, text: "999999", url: "img/ionic.png" },
            { id: 10, text: "aaaaaa", url: "img/ionic.png" }, { id: 11, text: "bbbbbb", url: "img/ionic.png" }, { id: 12, text: "cccccc", url: "img/ionic.png" },
            ];
        },
    }
}])